package com.dgut.service.impl;

import com.dgut.dao.IAccountDao;
import com.dgut.dao.impl.IAccountDaoImpl;
import com.dgut.domain.Account;
import com.dgut.service.IAccountService;
import com.dgut.utils.BeansFactory;

public class IAccountServiceImpl implements IAccountService {
    private IAccountDao  accountDao = new IAccountDaoImpl();

//    private IAccountDao  accountDao = BeansFactory.createAccountDao();
    /**
     * 转账的方法
     * @param account1
     * @param account2
     * @param money
     */
    public void trans(Account account1, Account account2, Integer money) {
//        System.out.println("日志开始.....");
        //1.更新账户1的余额
        account1.setMoney(account1.getMoney() - money);
        accountDao.update(account1);

        //2.更新账户2的余额
        account2.setMoney(account2.getMoney() + money);
        accountDao.update(account2);
//        System.out.println("日志结束.....");
    }

    public void findAccount(Integer id) {
//        System.out.println("日志开始.....");
        accountDao.findById(id);
//        System.out.println("日志结束.....");
    }


}
